<!--
Author: Quan Van Sinh
Email: sinhvnb@vietnambiz.com
-->
<?php
$login = new login();

if(!$login->checkLoginReturn()){
    if(isset($_POST['submit'])){
        //echo 'login khong thanh cong';die;
        $username = filter($_POST['username']);
        $password = filter($_POST['password']);
        if($login->login($username, $password)){
            $location = $config['domain'].'/'.$_SESSION['path'];
        }else{
            $location = $config['domain'].'/'.$config ['admin_section'].'/login';
        }
        header("Location: $location");
    }

}else{
    $location = $config['domain'];
    header("Location: $location");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Administration - Bantinnhadat.vn</title>
        <link rel="stylesheet" type="text/css" href="/admin/themes/default/css/login.css"/>
        <script type="text/javascript" src="/admin/themes/default/js/jquery.min.js"></script>
    </head>
    <body>
        <div id="cont">
            <script type='text/javascript'>
                $(document).ready(function(){
                    $('#lock').click(function(){
                        $("#loginform").toggle("slow");
                        $('#username').focus();
                    });
                    $('#cancel_submit').click(function(){
                        $("#loginform").toggle("slow");
                    });
                    $("form#signin").submit(function() {
                        var username = $("input#username").val();
                        if (username == "") {
                            $('#message').html("<font style='color:red'>All the fields are required.</font>");
                            $("#message").hide().fadeIn(1500);
                            $("input#username").focus();
                            return false;
                        }
                        var password = $("input#password").val();
                        if (password == "") {
                            $('#message').html("<font style='color:red'>All the fields are required.</font>");
                            $("#message").hide().fadeIn(1500);
                            $("input#password").focus();
                            return false;
                        }
                    });
                    $('.close').click(function(){
                        $("#loginform").toggle("slow");
                    });
                    $("#loginform").toggle("slow");
                    $('#username').focus();
                });

            </script>
            <div id="lock" class="box lock"> </div>
            <div id="loginform" class="box form">
                <h2>Authorization Required <a href="javascript:;" class="close">Close it</a></h2>
                <div class="formcont">
                    <fieldset id="signin_menu">
                        <span class="message" id="message">Please verify your account before continue</span>
                        <label class="error" id="error"></label>
                        <form method="post" id="signin" action="">
                            <label for="username">Username or email</label>
                            <input id="username" name="username" title="username" class="required" tabindex="4" type="text"/>
                            <p>
                                <label for="password">Password</label>
                                <input id="password" name="password" title="password" class="required" tabindex="5" type="password"/>
                            </p>
                            <p class="clear"></p>
                            <a href="#" style="display: none;" class="forgot" id="resend_password_link">Forgot your password?</a>
                            <p class="remember">
                                <input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit"/>
                                <input id="cancel_submit" value="Cancel" tabindex="7" type="button"/>
                            </p>
                        </form>
                    </fieldset>
                </div>
                <div class="formfooter"></div>
            </div>
        </div>
        <!-- Begin Full page background technique -->
        <div id="bg">
            <div>
                <table cellspacing="0" cellpadding="0">
                    <tr>
                        <td><img src="/admin/themes/default/images/login/bg.jpg" alt=""/> </td>
                    </tr>
                </table>
            </div>
        </div>
        <!-- End Full page background technique -->
    </body>
</html>